//
//  RGMessageAtMeCell.m
//  RedGrass
//
//  Created by wuyine on 2018/12/6.
//  Copyright © 2018年 hongcaosp. All rights reserved.
//

#import "RGMessageAtMeCell.h"

@interface RGMessageAtMeCell()

@end

@implementation RGMessageAtMeCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        self.contentView.backgroundColor = [UIColor blackColor];
        [self setSelectionStyle:UITableViewCellSelectionStyleNone];
        [self initChildUI];
        [self addChildMasonry];
    }
    return self;
}

- (void)setModel:(RGMessageContactModel *)model {
    [self.userIcon setImageWithURL:[NSURL URLWithString:model.image] placeholder:IMAGE_NAMED(@"头像1")];
    self.userName.text = model.nickname;
    if (model.typeChild == Message_Comment) {
        self.contentLabel.text = @"@了你的评论";
    }else if (model.typeChild == Message_Works) {
        self.contentLabel.text = @"@了你的作品";
    }
    self.dateLabel.text = [NSDate dateWithTimeStamp:[NSString stringWithFormat:@"%@",model.createTime] withFormatter:@"MM-dd HH:mm"];
    [self.image setImageWithURL:[NSURL URLWithString:model.coverPath] placeholder:IMAGE_NAMED(@"组6")];
}

-(void) initChildUI{
    [self.contentView addSubview:self.image];
    self.userName.font = FONT(customFontName,14);
    self.contentLabel.textColor = UICOLOR_WITH_RGBINT(0xffffff);
    self.contentLabel.font = FONT(customFontName, 16);
}

-(void) addChildMasonry {
    [_image mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(-15);
        make.size.mas_equalTo(CGSizeMake(65, 65));
        make.centerY.mas_equalTo(0);
    }];
    
    [self.dateLabel mas_updateConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.userIcon.mas_bottom).offset(3);
    }];
}

- (UIImageView *)image{
    if (!_image) {
        _image = [[UIImageView alloc] init];
        _image.image = IMAGE_NAMED(@"组6");
    }
    return _image;
}
@end
